package com.zx.callback.dao;

import com.zx.callback.po.PayThirdTrade;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public interface PayThirdTradeMapper {

    /**
     * 根据交易号获取支付订单信息
     * @param tradeNo
     * @return
     */
    PayThirdTrade getByTradeNo(@Param("tradeNo") String tradeNo);

    /**
     * 交易成功
     * @param id
     * @param tradeState
     * @param oldState
     * @param receiptAmount
     * @param outThirdTradeNo
     * @param tradeRealityTime
     * @return
     */
    int updateSuccess(@Param("id") Long id, @Param("tradeState") Byte tradeState, @Param("oldState") Byte oldState, @Param("receiptAmount") BigDecimal receiptAmount, @Param("outThirdTradeNo") String outThirdTradeNo, @Param("tradeRealityTime") Date tradeRealityTime);

    /**
     * 支付失败
     * @param id
     * @param oldState
     * @param tradeErrorCode
     * @param tradeErrorMessage
     * @return
     */
    int updateFail(@Param("id") Long id, @Param("oldState") Byte oldState, @Param("tradeErrorCode") String tradeErrorCode, @Param("tradeErrorMessage") String tradeErrorMessage);

    /**
     * 修改第三方支付返回信息
     * @param id
     * @param outThirdForm
     * @return
     */
    int updateOutThirdFormById(@Param("id") Long id, @Param("outThirdForm") String outThirdForm);


    /**
     * 修改交易流水号
     * @param id
     * @param tradeNo
     * @return
     */
    int updateTradeNoById(@Param("id") Long id, @Param("tradeNo") String tradeNo);


    /**
     * 查询该订单是否已经支付
     * @param tradeEvent
     * @param businessEvent
     * @param orderNo
     * @param buyerUserId
     * @return
     */
    int selectIsPayByOrderNo(@Param("tradeEvent") String tradeEvent, @Param("businessEvent") String businessEvent, @Param("orderNo") String orderNo, @Param("tradeStateList") List<Byte> tradeStateList, @Param("buyerUserId") String buyerUserId);

    /**
     * 查询等待中的订单
     * @param tradeEvent
     * @param businessEvent
     * @param orderNo
     * @param buyerUserId
     * @return
     */
    PayThirdTrade selectWaitPayInfo(@Param("tradeEvent") String tradeEvent, @Param("businessEvent") String businessEvent, @Param("orderNo") String orderNo, @Param("payMethod") String payMethod, @Param("buyerUserId") String buyerUserId);

    int deleteByPrimaryKey(Long id);

    int insert(PayThirdTrade record);

    int insertSelective(PayThirdTrade record);

    PayThirdTrade selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(PayThirdTrade record);

    int updateByPrimaryKey(PayThirdTrade record);
}